package fastwave.cloud.demo.fastwave.biz.publisher.controller;

import fastwave.cloud.demo.fastwave.biz.publisher.service.AccountService;
import fastwave.cloud.demo.fastwave.biz.publisher.service.TransService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>Title: AccountController</p>
 *
 * @author: dwLiu
 * @date: 2020/4/11 21:20
 */
@RestController
@RequestMapping("account")
public class AccountController {
    @Autowired
    private AccountService accountService;

    @Autowired
    private TransService transService;

    @GetMapping("/transfer")
    public String transfer(@RequestParam Map<String,Object> param) throws Exception{
        Integer id1 = Integer.parseInt(param.get("id1").toString());
        Integer id2 = Integer.parseInt(param.get("id2").toString());
        Float amount = Float.parseFloat(param.get("amount").toString());
        return accountService.transfer(id1,id2,amount);
    }
}
